package io.gbznt.modules.buss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import io.gbznt.common.utils.PageUtils;
import io.gbznt.common.utils.Query;

import io.gbznt.modules.buss.dao.BussActionRecordDao;
import io.gbznt.modules.buss.entity.BussActionRecordEntity;
import io.gbznt.modules.buss.service.BussActionRecordService;


@Service("bussActionRecordService")
public class BussActionRecordServiceImpl extends ServiceImpl<BussActionRecordDao, BussActionRecordEntity> implements BussActionRecordService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	String name=(String)params.get("name");//用户名
    	String time =(String)params.get("time");//时间段
    	String str1="";
    	String str2="";
    	if(StringUtils.isNotBlank(time)) {
    		String[] strs=time.split(" - ");
    		str1=strs[0];
    		str2=strs[1];
    	}   	
        IPage<BussActionRecordEntity> page = this.page(
                new Query<BussActionRecordEntity>().getPage(params),
                new QueryWrapper<BussActionRecordEntity>()
                .like(StringUtils.isNotBlank(name),"username", name)
                .between(StringUtils.isNotBlank(time), "create_time", str1, str2)
                .orderByDesc("create_time")
                
        );

        return new PageUtils(page);
    }

}
